package operation;
import book.BookList;
import java.util.Scanner;
public class DelOperation extends FindBook implements IOperation{
    @Override
    public void word(BookList bookList){
        System.out.println("删除图书!");
        System.out.println("请输入你要删除的图书:");
        Scanner scanner = new Scanner(System.in);
        String name = scanner.nextLine();
        int ret = findBook(bookList, name);
        if(ret != -1){
            for(; ret < bookList.getUsedSize() - 1; ret++){
                bookList.setBook(ret,bookList.getBook(ret + 1));
            }
            bookList.setBook(ret,null);
            bookList.setUsedSize(bookList.getUsedSize() - 1);

            System.out.println("删除成功!");
        }
        else{
            System.out.println("未找到图书!");
        }
    }

}
